﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GA.Shared.Interfaces;
using System.Windows;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Windows.Data;
using GA.Server.DatabaseManager;
using GA.Shared.Objects;

namespace GA.Server.Objects
{
    public class DatabaseCharacter : DatabaseObject
    {
        /// <summary>
        /// Identifies the Id Property.
        /// </summary>
        public static readonly DependencyProperty IdProperty =
            DependencyProperty.Register(
                "Id",
                typeof(int),
                typeof(DatabaseCharacter),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the GameId Property.
        /// </summary>
        public static readonly DependencyProperty GameIdProperty =
            DependencyProperty.Register(
                "GameId",
                typeof(int),
                typeof(DatabaseCharacter),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the GameClassId Property.
        /// </summary>
        public static readonly DependencyProperty GameClassIdProperty =
            DependencyProperty.Register(
                "GameClassId",
                typeof(int),
                typeof(DatabaseCharacter),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the GameClass Property.
        /// </summary>
        public static readonly DependencyProperty GameClassProperty =
            DependencyProperty.Register(
                "GameClass",
                typeof(GameClass),
                typeof(DatabaseCharacter),
                new PropertyMetadata(null));


        /// <summary>
        /// Identifies the Items Property.
        /// </summary>
        public static readonly DependencyProperty ItemsProperty =
            DependencyProperty.Register(
                "Items",
                typeof(ObservableCollection<Item>),
                typeof(DatabaseCharacter),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the Skills Property.
        /// </summary>
        public static readonly DependencyProperty SkillsProperty =
            DependencyProperty.Register(
                "Skills",
                typeof(ObservableCollection<Skill>),
                typeof(DatabaseCharacter),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the PlayerId Property.
        /// </summary>
        public static readonly DependencyProperty PlayerIdProperty =
            DependencyProperty.Register(
                "PlayerId",
                typeof(int),
                typeof(DatabaseCharacter),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the Player Property.
        /// </summary>
        public static readonly DependencyProperty PlayerProperty =
            DependencyProperty.Register(
                "Player",
                typeof(Player),
                typeof(DatabaseCharacter),
                new PropertyMetadata(-1));


        /// <summary>
        /// Gets or sets the Id.
        /// </summary>
        
        [DatabaseField("Id", IsIdentity = true, IsKey = true)]
        public int Id
        {
            get { return (int)SafeGetValue(IdProperty); }
            set { SafeSetValue(IdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Game Id.
        /// </summary>
        
        [DatabaseField("GameId", IsKey = true)]
        public int GameId
        {
            get { return (int)SafeGetValue(GameIdProperty); }
            set { SafeSetValue(GameIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the GameClass Id.
        /// </summary>
        
        [DatabaseField("CharacterId")]
        public int GameClassId
        {
            get { return (int)SafeGetValue(GameClassIdProperty); }
            set { SafeSetValue(GameClassIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the GameClass.
        /// </summary>
        
        public GameClass GameClass
        {
            get { return (GameClass)SafeGetValue(GameClassProperty); }
            set { SafeSetValue(GameClassProperty, value); }
        }


        /// <summary>
        /// Gets or sets the Items.
        /// </summary>
        
        public ObservableCollection<Item> Items
        {
            get { return (ObservableCollection<Item>)SafeGetValue(ItemsProperty); }
            set { SafeSetValue(ItemsProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Skills.
        /// </summary>
        
        public ObservableCollection<Skill> Skills
        {
            get { return (ObservableCollection<Skill>)SafeGetValue(SkillsProperty); }
            set { SafeSetValue(SkillsProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Player Id.
        /// </summary>
        
        [DatabaseField("PlayerId")]
        public int PlayerId
        {
            get { return (int)SafeGetValue(PlayerIdProperty); }
            set { SafeSetValue(PlayerIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Player.
        /// </summary>
        
        public Player Player
        {
            get { return (Player)SafeGetValue(PlayerProperty); }
            set { SafeSetValue(PlayerProperty, value); }
        }

        public DatabaseCharacter()
        {
        }

        public DatabaseCharacter(LinkedDependencyObject baseCharacter)
            : base(baseCharacter)
        {
        }

        public DatabaseCharacter(LinkedDependencyObject baseCharacter, BindingMode bindingMode)
            : base(baseCharacter, bindingMode)
        {
        }

        public override void LoadAllPropertyObjects()
        {
            #warning Not Implemented
        }

        public override void LoadPropertyObject(string propertyName)
        {
            #warning Not Implemented
        }
    }
}
